package com.example.test.advice.第四章_字符串.建议52_推荐使用String直接量赋值;

public class StringClient {

    public static void main(String[] args) {
        String str1 = "中国";
        String str2 = "中国";
        String str3 = new String("中国");
        String str4 = str3.intern();//将值放入常量池，并返回常量池的引用
        System.out.println("str4:"+str4);
        //两个直接量是否相等
        boolean b1 = (str1 == str2);
        //直接量和对象是否相等
        boolean b2 = (str1 == str3);
        //经过intern处理后的对象与直接量是否相等
        boolean b3 = (str1 == str4);
        System.out.println("b1:"+b1+",b2:"+b2+",b3:"+b3);
    }
}
